//write
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <pthread.h>
#include <stdio.h>
#include <sys/wait.h>

#define PIPE_NAME "/tmp/myfifo"
int main(int argc,char*argv[])
{
    int ret=0;
    int wfd=0;
    char buf[8]="";
    if(access(PIPE_NAME,F_OK))
    {
        ret = mkfifo(PIPE_NAME,0666);
        if (ret<0)
        {
            printf("error");
            return 1;
        }
        
    }
    printf("write process before open\n");
    wfd = open(PIPE_NAME,O_WRONLY);
    printf("write process after open\n");
    if(wfd < 0)
    {
        printf("error");
        return 2;
    }
    write(wfd,"Hello",6);
    
    close(wfd);
    wfd = -1;
    return 0;
}